<?php
namespace app\mobile\middleware;

use app\admin\model\Platform;
use app\admin\model\UserToken;
use Firebase\JWT\JWT;
use think\Request;
use think\facade\Log;
header("content-type:text/html;charset=utf-8");

/**
 * 检测白名单
 * Class CheckWhite
 *
 * @package app\mobile\middleware
 */
class PlatformInfo
{
    public function handle(Request $request, \Closure $next)
    {
        $domain = $_SERVER['HTTP_HOST'];
        $platformModel = new Platform();
        $platformInfo = $platformModel->where(['url'=> $domain])->find();
        //qmkqzz.weijuyunke.cn
        if ($platformInfo){
            $request->platform_id = $platformInfo['id'];
        }else{
            return msg([], 401, '配置有误' );
        }
        if ($platformInfo['expiration_time'] < time()){
            return msg([], 401, '平台过期' );
        }

        return $next($request);

    }
}